package com.character.controller;



import com.character.entity.MyReturn;
import com.character.service.MailService;

import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.mail.MessagingException;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.sql.SQLOutput;
import java.util.Base64;
import java.io.OutputStream;

import static javax.xml.crypto.dsig.Transform.BASE64;


/**
 * @author 张燕豪
 * @description 发送邮件
 * @date 2021/12/8
 */
@RestController
@RequestMapping("mail")
public class MailController extends BaseController{
    @Resource
    private MailService mailService;
    /*** *
     * @Author 张燕豪
     * @Description 设置邮件内容
     * @data 14:42 2021/12/8
     * @return int 0 1
     */
    @GetMapping("setMail")
    public MyReturn setEmil(String email,String text){
        String to = email;
        String subject = text;
        String rscId = "img110";
        String content = "<html><body><img width='250px' src=\'cid:" + rscId + "\'></body></html>";

        String imgPath="src/main/resources/static/imgs/the1.png";
        try {
            mailService.sendInlineResourceMail(to, subject, content, imgPath, rscId);
        } catch (MessagingException e) {
            e.printStackTrace();
        }
        return super.success(null);//成功返回0
    }

}
